//
//  MyMessageContentCell.m
//  BusinessMarket
//
//  Created by Michael Li on 2018/11/28.
//  Copyright © 2018年 Michael Li. All rights reserved.
//

#import "MyMessageContentCell.h"
#import "MessageModel.h"
#import "TimeHelper.h"
@interface MyMessageContentCell()
@property (weak, nonatomic) IBOutlet UILabel *timeL;
@property (weak, nonatomic) IBOutlet UILabel *readCountL;

@end
@implementation MyMessageContentCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.timeL.textColor = kLabel153Color;
    self.readCountL.textColor = kLabel153Color;
}

- (void)setMsgModel:(MessageModel *)msgModel
{
    _msgModel = msgModel;
    NSTimeInterval interval    = msgModel.createtime/1000.0;
    NSDate *date               = [NSDate dateWithTimeIntervalSince1970:interval];
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"MM-dd HH:mm"];
    NSString *currentDateStr = [formatter stringFromDate: date];
    
    self.readCountL.text = [NSString stringWithFormat:@"阅读 %ld",msgModel.readcount];

    if (msgModel.createtime >=[[TimeHelper currentZeroTime] integerValue]  ) {//今天
        [formatter setDateFormat:@"HH:mm"];
        NSString *currentDateStr = [formatter stringFromDate: date];
        self.timeL.text = [NSString stringWithFormat:@"今天:%@",currentDateStr];
    }else if (msgModel.createtime >=[[TimeHelper currentZeroTime] integerValue]-24*60*60*1000&& msgModel.createtime<[[TimeHelper currentZeroTime] integerValue] ){//昨天
        self.timeL.text = [NSString stringWithFormat:@"昨天:%@",currentDateStr];
    }else {
        self.timeL.text = currentDateStr;
    }
}

@end
